; ModuleID = 'tests/m3/fibonacci.bal'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-linux-gnu"

@.fmt_d = private constant [3 x i8] c"%d\00", align 1 ; <[3 x i8]*> [#uses=1]
@.fmt_s = private constant [3 x i8] c"%s\00", align 1 ; <[3 x i8]*> [#uses=1]
@0 = internal constant [2 x i8] c"\0A\00", align 1 ; <[2 x i8]*> [#uses=1]

declare i32 @printf(i8* nocapture, ...) nounwind

declare i32 @scanf(i8* nocapture, ...) nounwind

define i32 @fib(i32 %n) nounwind readnone {
entry:
  %tmp6 = icmp slt i32 %n, 2                      ; <i1> [#uses=1]
  br i1 %tmp6, label %if.then, label %if.else

if.then:                                          ; preds = %entry
  ret i32 %n

if.else:                                          ; preds = %entry
  %tmp9 = add i32 %n, -1                          ; <i32> [#uses=2]
  %tmp6.i2 = icmp slt i32 %tmp9, 2                ; <i1> [#uses=1]
  br i1 %tmp6.i2, label %fib.exit9, label %if.else.i7

if.else.i7:                                       ; preds = %if.else
  %tmp9.i4 = add i32 %n, -2                       ; <i32> [#uses=1]
  %"<call>.i5" = tail call i32 @fib(i32 %tmp9.i4) nounwind ; <i32> [#uses=1]
  %tmp11.i6 = add i32 %n, -3                      ; <i32> [#uses=2]
  %tmp6.i.i = icmp slt i32 %tmp11.i6, 2           ; <i1> [#uses=1]
  br i1 %tmp6.i.i, label %fib.exit.i, label %if.else.i.i

if.else.i.i:                                      ; preds = %if.else.i7
  %tmp9.i.i = add i32 %n, -4                      ; <i32> [#uses=1]
  %"<call>.i.i" = tail call i32 @fib(i32 %tmp9.i.i) nounwind ; <i32> [#uses=1]
  %tmp11.i.i = add i32 %n, -5                     ; <i32> [#uses=1]
  %"<call>5.i.i" = tail call i32 @fib(i32 %tmp11.i.i) nounwind ; <i32> [#uses=1]
  %"+.i.i" = add i32 %"<call>5.i.i", %"<call>.i.i" ; <i32> [#uses=1]
  br label %fib.exit.i

fib.exit.i:                                       ; preds = %if.else.i.i, %if.else.i7
  %"<call>51.i" = phi i32 [ %"+.i.i", %if.else.i.i ], [ %tmp11.i6, %if.else.i7 ] ; <i32> [#uses=1]
  %"+.i8" = add i32 %"<call>51.i", %"<call>.i5"   ; <i32> [#uses=1]
  br label %fib.exit9

fib.exit9:                                        ; preds = %fib.exit.i, %if.else
  %"<call>10" = phi i32 [ %"+.i8", %fib.exit.i ], [ %tmp9, %if.else ] ; <i32> [#uses=1]
  %tmp11 = add i32 %n, -2                         ; <i32> [#uses=2]
  %tmp6.i = icmp slt i32 %tmp11, 2                ; <i1> [#uses=1]
  br i1 %tmp6.i, label %fib.exit, label %if.else.i

if.else.i:                                        ; preds = %fib.exit9
  %tmp9.i = add i32 %n, -3                        ; <i32> [#uses=1]
  %"<call>.i" = tail call i32 @fib(i32 %tmp9.i) nounwind ; <i32> [#uses=1]
  %tmp11.i = add i32 %n, -4                       ; <i32> [#uses=1]
  %"<call>5.i" = tail call i32 @fib(i32 %tmp11.i) nounwind ; <i32> [#uses=1]
  %"+.i" = add i32 %"<call>5.i", %"<call>.i"      ; <i32> [#uses=1]
  br label %fib.exit

fib.exit:                                         ; preds = %if.else.i, %fib.exit9
  %"<call>51" = phi i32 [ %"+.i", %if.else.i ], [ %tmp11, %fib.exit9 ] ; <i32> [#uses=1]
  %"+" = add i32 %"<call>51", %"<call>10"         ; <i32> [#uses=1]
  ret i32 %"+"
}

define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
entry:
  %i = alloca i32, align 4                        ; <i32*> [#uses=4]
  store i32 0, i32* %i
  %tmp5 = call i32 (i8*, ...)* @scanf(i8* noalias getelementptr inbounds ([3 x i8]* @.fmt_d, i64 0, i64 0), i32* %i) nounwind ; <i32> [#uses=0]
  %i1 = load i32* %i                              ; <i32> [#uses=1]
  %"<call>" = call i32 @fib(i32 %i1)              ; <i32> [#uses=2]
  store i32 %"<call>", i32* %i
  %printf = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([3 x i8]* @.fmt_d, i64 0, i64 0), i32 %"<call>") ; <i32> [#uses=0]
  %printf3 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([3 x i8]* @.fmt_s, i64 0, i64 0), [2 x i8]* @0) ; <i32> [#uses=0]
  ret i32 0
}
